package com.kg.fiber.service;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.ivan.toolkit.common.Directory;

import lombok.extern.log4j.Log4j;

@Component
@Log4j
public class Guardor {
	
	private static final long GB = 1024 * 1024 * 1024;
	
	private static Directory logDir = new Directory("fiber_logs");
	
	@Scheduled(cron="0 0/5 *  * * ? ")   
    public void doScheduled() {
				
		log.info("schedule for store guard.");
		
		long storeLimit = 150 * GB;
		
		// 自动删除超过存储周期的数据文件
		// 
		
		Store.dir.guardMaxTotalLength(storeLimit);
		
		
		logDir.guardMaxFileCount(60);
		
	}
	
}
